<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: gv_sent.php 55 2013-09-21 11:57:53Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 55 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:57:53 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

require(DIR_WS_INCLUDES . 'metatag.php'); ?>

</head>
<body>
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<div id="wrapper">
	<table class="outerTable">
  		<tr>
    		<td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
				<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
			</td>
    		<td class="boxCenter" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		      <tr>
		        <td width="100%">
					<table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
		   				<tr>
		     				<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
						</tr>
					</table>
				</td>
		      </tr>
		      <tr>
		        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
		          <tr>
		            <td valign="top"><table class="dataTable" border="0" width="100%" cellspacing="0" cellpadding="2">
		              <tr class="dataTableHeadingRow">
		                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_SENDERS_NAME; ?></td>
		                <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_VOUCHER_VALUE; ?></td>
		                <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_VOUCHER_CODE; ?></td>
		                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_DATE_SENT; ?></td>		
		                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
		              </tr>
<?php

	if($_GET['delete'] == '1') {
		$db->db_query("DELETE FROM " . TABLE_COUPONS . " WHERE coupon_id = '".(int)$_GET['gID']."' ");
		$db->db_query("DELETE FROM " . TABLE_COUPON_EMAIL_TRACK . " WHERE coupon_id = '".(int)$_GET['gID']."' ");	
	}
	
  $gv_list = $db->db_query("SELECT c.coupon_amount, c.coupon_code, c.coupon_id, et.sent_firstname, et.sent_lastname, et.customer_id_sent, et.emailed_to, et.date_sent, c.coupon_id from " . TABLE_COUPONS . " c, " . TABLE_COUPON_EMAIL_TRACK . " et WHERE c.coupon_id = et.coupon_id");

  while (!$gv_list->EOF) {
    if (((!$_GET['gid']) || (@$_GET['gid'] == $gv_list->fields['coupon_id'])) && (!$gInfo)) {
    $gInfo = new objectInfo($gv_list->fields);
    }
    if ( (is_object($gInfo)) && ($gv_list->fields['coupon_id'] == $gInfo->coupon_id) ) {
      echo '              <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . href_link('gv_sent.php', get_all_get_params(array('gid', 'action')) . 'gid=' . $gInfo->coupon_id . '&action=edit') . '\'">' . "\n";
    } else {
      echo '              <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . href_link('gv_sent.php', get_all_get_params(array('gid', 'action')) . 'gid=' . $gv_list->fields['coupon_id']) . '\'">' . "\n";
    }
?>
                <td class="dataTableContent"><?php echo $gv_list->fields['sent_firstname'] . ' ' . $gv_list->fields['sent_lastname']; ?></td>
                <td class="dataTableContent" align="center"><?php echo $currencies->format($gv_list->fields['coupon_amount']); ?></td>
                <td class="dataTableContent" align="center"><?php echo $gv_list->fields['coupon_code']; ?></td>
                <td class="dataTableContent" align="right"><?php echo date_short($gv_list->fields['date_sent']); ?></td>
                <td class="dataTableContent" align="right"><?php if ( (is_object($gInfo)) && ($gv_list->fields['coupon_id'] == $gInfo->coupon_id) ) { echo image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . href_link(FILENAME_GV_SENT, 'page=' . $_GET['page'] . '&gid=' . $gv_list->fields['coupon_id']) . '">' . image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
<?php
	echo '</tr>';
	!$gv_list->MoveNext();
  }
?>
              <tr>
                <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"></td>
                    <td class="smallText" align="right"></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
			<?php
			  $heading = array();
			  $contents = array();

			  $heading[] = array('text' => '[' . $gInfo->coupon_id . '] ' . ' ' . $currencies->format($gInfo->coupon_amount));
			  $redeem = $db->db_query("SELECT * from " . TABLE_COUPON_REDEEM_TRACK . " WHERE coupon_id = '" . $gInfo->coupon_id . "'");
			  $redeemed = 'No';
			  if ($redeem->_numOfRows) $redeemed = 'Yes';
			  $contents[] = array('align' => 'center','text' => '<form action=""><a href="'.href_link(FILENAME_GV_SENT,'page='.$_GET['page'].'&delete=1&gID='.$gInfo->coupon_id).'" class="button">'.TABLE_HEADING_VOUCHER_CODE. ' ' .BUTTON_DELETE.'</a>');
			  $contents[] = array('text' => TEXT_INFO_SENDERS_ID . ' ' . $gInfo->customer_id_sent);
			  $contents[] = array('text' => TEXT_INFO_AMOUNT_SENT . ' ' . $currencies->format($gInfo->coupon_amount));
			  $contents[] = array('text' => TEXT_INFO_DATE_SENT . ' ' . date_short($gInfo->date_sent));
			  $contents[] = array('text' => TEXT_INFO_VOUCHER_CODE . ' ' . $gInfo->coupon_code);
			  $contents[] = array('text' => TEXT_INFO_EMAIL_ADDRESS . ' ' . $gInfo->emailed_to);
			  if ($redeemed=='Yes') {
			    $contents[] = array('text' => '<br />' . TEXT_INFO_DATE_REDEEMED . ' ' . date_short($redeem->fields['redeem_date']));
			    $contents[] = array('text' => TEXT_INFO_IP_ADDRESS . ' ' . $redeem->fields['redeem_ip']);
			    $contents[] = array('text' => TEXT_INFO_CUSTOMERS_ID . ' ' . $redeem->fields['customer_id']);
			  } else {
			    $contents[] = array('text' => '<br />' . TEXT_INFO_NOT_REDEEMED);
			  }

			  if ( (not_null($heading)) && (not_null($contents)) ) {
			    echo '            <td width="25%" class="border" valign="top">' . "\n";

			    $box = new box;
			    echo $box->infoBox($heading, $contents);

			    echo '            </td>' . "\n";
			  }
			?>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<br />
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>